Make 01_reboot test more robust.
authordan@guaranine.beaverton.ibm.com <dan@guaranine.beaverton.ibm.com>
Wed, 16 Nov 2005 19:32:36 +0000 (20:32 +0100)
committerdan@guaranine.beaverton.ibm.com <dan@guaranine.beaverton.ibm.com>
Wed, 16 Nov 2005 19:32:36 +0000 (20:32 +0100)
We need to attach a console before rebooting to make sure the domain did
actually boot in the first place.  Also, use a better method for pulling out
the uptime string.

tools/xm-test/tests/reboot/01_reboot_basic_pos.py

index 8037d44c130b938b32c7e86e32de7ea91bbe92d3..e33c93a28fe462d8a584ab5343ba6b2e7e51cbf6 100644 (file)
@@ -18,6 +18,13 @@ except DomainError, e:
         print e.extra
     FAIL(str(e))
 
+try:
+    console = XmConsole(domain.getName())
+except ConsoleError, e:
+    FAIL(str(e))
+
+console.closeConsole()
+
 status, output = traceCommand("xm reboot %s" % domain.getName())
 
 if status != 0:
@@ -40,8 +47,11 @@ console.closeConsole()
 
 domain.destroy()
 
-items = re.split(" +", run["output"])
-uptime = int(items[3])
-if uptime > 1:
-    FAIL("Uptime too large (%i > 1 minutes); domain didn't reboot")
+match = re.match("^[^up]*up ([0-9]+).*$", run["output"])
+if match:
+    if int(match.group(1)) > 1:
+        FAIL("Uptime too large (%i > 1 minutes); domain didn't reboot")
+else:
+    FAIL("Invalid uptime string: %s (%s)" % (run["output"], match.group(1)))
+